asm
  ;org $1000
  ld sp,$08FF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"
#include "./library/charmap01.bas"
#include "./library/minivadersldirxor32b.bas"

dim i as uinteger at $0810
dim eee as uinteger at $0812
dim seed as uinteger at $0814
dim eex as uinteger at $0816
dim eey as uinteger at $0818
dim eey2 as uinteger at $081A
dim ejst as uinteger at $081C
dim exps as uinteger at $081E
dim eyps as uinteger at $0820
dim eqq as uinteger at $0822
dim delay as uinteger at $0824
dim seed2 as uinteger at $0826
dim clcur as uinteger at $0828

sub putchar(txpos as uinteger,typos as uinteger,tch as uinteger, tadr as uinteger,txor as ubyte,tattr as ubyte)
  minivadersldirxor32b($4000+(txpos band 31)+(((typos mod 32)+4)*256),tadr+(tch*8),8,txor   )
  poke $8000+(txpos band 31)+ 0+(((typos mod 32)+4)*64),(tattr band $F)*$11
  poke $8000+(txpos band 31)+32+(((typos mod 32)+4)*64),(tattr band $F)*$11
  end sub

sub writetext(txpos2 as uinteger,typos2 as uinteger,ttxt as uinteger, tleng as uinteger,tadr2 as uinteger, txor2 as uinteger,tattr2 as ubyte)
  dim trt2 as uinteger at $A002
  for trt2=0 to tleng-1
    putchar(txpos2+trt2,typos2,peek(ttxt+trt2),tadr2,txor2,tattr2)
    next
  end sub

for eey=0 to 27
  for eex=0 to 31
    seed=smsrnd(seed)
    seed2=seed
    seed=smsrnd(seed)
    putchar(eex,eey,96+(seed mod 9),@charmap01-256,$FF,seed2)
    next:next

for eey=0 to 7
  for eex=0 to 15
    putchar(eex+15,eey+11,eex+(eey*16),@charmap01-256,$FF,15)
    putchar(eex+15,eey+19,eex+(eey*16),@charmap01-256,$00,15)
    next:next

for eey=0 to 1
  for eex=0 to 7
    putchar(eex+1,eey+25,$20,@charmap01-256,$FF,eey*8+eex)
    next:next

writetext(15,9,@text01,14,@charmap01-256,$00,%1010)

exps=4
eyps=4
eee=0
clcur=10*4

do
  putchar(3,11,48+ (eee mod 10)  ,@charmap01-256,$FF,14)
  putchar(2,11,48+ ( int(eee/10) mod 10)  ,@charmap01-256,$FF,14)
  putchar(1,11,48+ ( int(eee/100) mod 10)  ,@charmap01-256,$FF,14)

  ejst=in($49) bxor 255
  putchar(3,14,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,14,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,14,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)

  ejst=in($4A) bxor 255
  putchar(3,15,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,15,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,15,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)

  ejst=in($60) bxor 255
  putchar(3,16,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,16,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,16,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)

  ejst=in($48) bxor 255
  putchar(3,13,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,13,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,13,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)
  if (ejst band 1)<>0 then:exps=exps-1:end if
  if (ejst band 2)<>0 then:exps=exps+1:end if

'-----------------------------------------------------
'$07F8
'-----------------------------------------------------
'- this will allocate the code to the second part of the rom, after ram area
'- first part: $0000 to $07FF (2kb) - second part: $1000 to $37FF (10kb)
'- copied from a code made for Casio PV1000
goto flg01:
asm
  org $1000
  end asm
flg01:
'-----------------------------------------------------
'$1000
'-----------------------------------------------------

  if (ejst band 4)<>0 then:eyps=eyps-1:end if
  if (ejst band 8)<>0 then:eyps=eyps+1:end if
  if (ejst band 16)<>0 then:clcur=clcur+1:end if
  eqq=96+(eee mod 9)
  if (ejst band 4)<>0 then:eqq=96+4:end if
  putchar(exps,eyps,eqq,@charmap01-256,$FF,int(clcur/4))

  ejst=in($61) bxor 255
  putchar(3,17,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,17,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,17,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)

  ejst=in($65) bxor 255
  putchar(3,18,48+ (ejst mod 10)  ,@charmap01-256,$FF,11)
  putchar(2,18,48+ ( int(ejst/10) mod 10)  ,@charmap01-256,$FF,11)
  putchar(1,18,48+ ( int(ejst/100) mod 10)  ,@charmap01-256,$FF,11)

  pacmandelay(1000)

  eee=eee+1
  loop


pacmandelay(10000)
seed=0

do

  for eee=0 to 3
    for i=$8000 to $87FF
     seed=smsrnd(seed)
     poke i,seed
      pacmandelay(1000)
      next
    next

  for i=$0000 to $1FFF
    seed=smsrnd(seed)
    poke $4000+i,seed
    poke $6000+i,seed
    pacmandelay(100)
    next

  loop

do
  loop

text01:
asm
  defb "HELLO WORLD!!!!!"
  end asm






